<template>
  <div class="app-container">
    <el-form :model="queryParams" ref="queryForm" :inline="true" v-show="showSearch" label-width="130px">
      <el-form-item label="UserID" prop="userId">
        <el-input
          v-model="queryParams.userId"
          placeholder="请输入UserID"
          clearable
          size="small"
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="CustNo" prop="custNo">
        <el-input
          v-model="queryParams.custNo"
          placeholder="请输入客户号"
          clearable
          size="small"
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
<!--      <el-form-item label="月收入" prop="monthlyIncome">-->
<!--        <el-input-->
<!--          v-model="queryParams.monthlyIncome"-->
<!--          placeholder="请输入月收入"-->
<!--          clearable-->
<!--          size="small"-->
<!--          @keyup.enter.native="handleQuery"-->
<!--        />-->
<!--      </el-form-item>-->
<!--      <el-form-item label="邮箱" prop="email">-->
<!--        <el-input-->
<!--          v-model="queryParams.email"-->
<!--          placeholder="请输入邮箱"-->
<!--          clearable-->
<!--          size="small"-->
<!--          @keyup.enter.native="handleQuery"-->
<!--        />-->
<!--      </el-form-item>-->
<!--      <el-form-item label="工作职称" prop="jobTitle">-->
<!--        <el-select v-model="queryParams.jobTitle" placeholder="请选择工作职称" clearable size="small">-->
<!--          <el-option-->
<!--            v-for="dict in jobTitleOptions"-->
<!--            :key="dict.dictValue"-->
<!--            :label="dict.dictLabel"-->
<!--            :value="dict.dictValue"-->
<!--          />-->
<!--        </el-select>-->
<!--      </el-form-item>-->
      <el-form-item label="industry" prop="industry">
        <el-select v-model="queryParams.industry" placeholder="请选择行业" clearable size="small">
          <el-option
            v-for="dict in industryOptions"
            :key="dict.dictValue"
            :label="dict.dictLabel"
            :value="dict.dictValue"
          />
        </el-select>
      </el-form-item>
      <el-form-item label="Marital Status" prop="maritalStatus">
        <el-select v-model="queryParams.maritalStatus" placeholder="请选择婚姻状态" clearable size="small">
          <el-option
            v-for="dict in maritalStatusOptions"
            :key="dict.dictValue"
            :label="dict.dictLabel"
            :value="dict.dictValue"
          />
        </el-select>
      </el-form-item>
      <el-form-item label="Degree" prop="degree">
        <el-select v-model="queryParams.degree" placeholder="请选择学历" clearable size="small">
          <el-option
            v-for="dict in degreeOptions"
            :key="dict.dictValue"
            :label="dict.dictLabel"
            :value="dict.dictValue"
          />
        </el-select>
      </el-form-item>
<!--      <el-form-item label="职业" prop="occupation">-->
<!--        <el-select v-model="queryParams.occupation" placeholder="请选择职业" clearable size="small">-->
<!--          <el-option-->
<!--            v-for="dict in occupationOptions"-->
<!--            :key="dict.dictValue"-->
<!--            :label="dict.dictLabel"-->
<!--            :value="dict.dictValue"-->
<!--          />-->
<!--        </el-select>-->
<!--      </el-form-item>-->
      <el-form-item label="Relate Name" prop="relateName">
        <el-input
          v-model="queryParams.relateName"
          placeholder="请输入联系人姓名"
          clearable
          size="small"
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="Relate Phone" prop="relatePhone">
        <el-input
          v-model="queryParams.relatePhone"
          placeholder="请输入联系人号码"
          clearable
          size="small"
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="relation" prop="relation">
        <el-select v-model="queryParams.relation" placeholder="请选择关系" clearable size="small">
          <el-option
            v-for="dict in relationOptions"
            :key="dict.dictValue"
            :label="dict.dictLabel"
            :value="dict.dictValue"
          />
        </el-select>
      </el-form-item>
<!--      <el-form-item label="学历更新时间" prop="degreeUpdated">-->
<!--        <el-date-picker clearable size="small"-->
<!--                        v-model="queryParams.degreeUpdated"-->
<!--                        type="date"-->
<!--                        value-format="yyyy-MM-dd"-->
<!--                        placeholder="选择学历更新时间">-->
<!--        </el-date-picker>-->
<!--      </el-form-item>-->
<!--      <el-form-item label="职业更新时间" prop="occupationUpdated">-->
<!--        <el-date-picker clearable size="small"-->
<!--                        v-model="queryParams.occupationUpdated"-->
<!--                        type="date"-->
<!--                        value-format="yyyy-MM-dd"-->
<!--                        placeholder="选择职业更新时间">-->
<!--        </el-date-picker>-->
<!--      </el-form-item>-->
<!--      <el-form-item label="联系人更新时间" prop="relateUpdated">-->
<!--        <el-date-picker clearable size="small"-->
<!--                        v-model="queryParams.relateUpdated"-->
<!--                        type="date"-->
<!--                        value-format="yyyy-MM-dd"-->
<!--                        placeholder="选择联系人更新时间">-->
<!--        </el-date-picker>-->
<!--      </el-form-item>-->
      <el-form-item label="State" prop="state">
        <el-select v-model="queryParams.state" placeholder="请选择状态" clearable size="small">
          <el-option
            v-for="dict in stateOptions"
            :key="dict.dictValue"
            :label="dict.dictLabel"
            :value="dict.dictValue"
          />
        </el-select>
      </el-form-item>
      <el-form-item>
        <el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
        <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
      </el-form-item>
    </el-form>

    <el-row :gutter="10" class="mb8">
      <el-col :span="1.5">
        <el-button
          type="primary"
          plain
          icon="el-icon-plus"
          size="mini"
          @click="handleAdd"
          v-hasPermi="['bizsys:customer_info:add']"
        >新增
        </el-button>
      </el-col>
      <el-col :span="1.5">
        <el-button
          type="success"
          plain
          icon="el-icon-edit"
          size="mini"
          :disabled="single"
          @click="handleUpdate"
          v-hasPermi="['bizsys:customer_info:edit']"
        >修改
        </el-button>
      </el-col>
      <el-col :span="1.5">
        <el-button
          type="danger"
          plain
          icon="el-icon-delete"
          size="mini"
          :disabled="multiple"
          @click="handleDelete"
          v-hasPermi="['bizsys:customer_info:remove']"
        >删除
        </el-button>
      </el-col>
      <el-col :span="1.5">
        <el-button
          type="warning"
          plain
          icon="el-icon-download"
          size="mini"
          @click="handleExport"
          v-hasPermi="['bizsys:customer_info:export']"
        >导出
        </el-button>
      </el-col>
      <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
    </el-row>

    <el-table v-loading="loading" :data="customer_infoList" @selection-change="handleSelectionChange">
      <el-table-column type="selection" width="55" align="center"/>
      <el-table-column label="ID" align="center" width="100" prop="id"/>
      <el-table-column label="UserID" align="center" width="300" prop="userId"/>
      <el-table-column label="CustNo" align="center" width="200" prop="custNo"/>
      <el-table-column label="Monthly Income" align="center" width="150" prop="monthlyIncome"/>
      <el-table-column label="Email" align="center" width="200" prop="email"/>
      <el-table-column label="JobTitle" align="center" width="200" prop="jobTitle" :formatter="jobTitleFormat"/>
      <el-table-column label="工作职称-其他" align="center" prop="jobTitleOther" />
      <el-table-column label="Industry" align="center" width="250" prop="industry" :formatter="industryFormat"/>
      <el-table-column label="Marital Status" align="center" width="120" prop="maritalStatus" :formatter="maritalStatusFormat"/>
      <el-table-column label="Degree" align="center" width="200" prop="degree" :formatter="degreeFormat"/>
      <el-table-column label="Occupation" align="center" width="200" prop="occupation" :formatter="occupationFormat"/>
      <el-table-column label="职业-其他" align="center" prop="occupationOther" />
      <el-table-column label="Relate Name" align="center" width="200" prop="relateName"/>
      <el-table-column label="Relate Phone" align="center" width="180" prop="relatePhone"/>
      <el-table-column label="relation" align="center" width="100" prop="relation" :formatter="relationFormat"/>
      <el-table-column label="联系人2" align="center" prop="relateName2" />
      <el-table-column label="联系人手机号码2" align="center" prop="relatePhone2" />
      <el-table-column label="联系人关系2" align="center" prop="relation2" />
      <el-table-column label="复工时间" align="center" prop="resumptionDate" />
      <el-table-column label="发薪时间" align="center" prop="salaryDate" />
      <el-table-column label="工作地" align="center" prop="workingAddress" />
      <el-table-column label="工作地街道" align="center" prop="street" />
      <el-table-column label="居住地" align="center" prop="stateOfResidence" />
      <el-table-column label="孩子个数" align="center" prop="childrenNumber" />
      <el-table-column label="宗教" align="center" prop="religion" />
      <el-table-column label="母语" align="center" prop="nativeLanguage" />
      <el-table-column label="测算提额" align="center" prop="preLine" />
      <el-table-column label="模型评级" align="center" prop="modelLevel" />
      <el-table-column label="征信有效期(天数)" align="center" prop="expiryDate" />
      <el-table-column label="Degree Updated" align="center" prop="degreeUpdated" width="180">
        <template slot-scope="scope">
          <span>{{ parseTime(scope.row.degreeUpdated, '{y}-{m}-{d}') }}</span>
        </template>
      </el-table-column>
      <el-table-column label="Occupation Updated" align="center" prop="occupationUpdated" width="180">
        <template slot-scope="scope">
          <span>{{ parseTime(scope.row.occupationUpdated, '{y}-{m}-{d}') }}</span>
        </template>
      </el-table-column>
      <el-table-column label="Relate Updated" align="center" prop="relateUpdated" width="180">
        <template slot-scope="scope">
          <span>{{ parseTime(scope.row.relateUpdated, '{y}-{m}-{d}') }}</span>
        </template>
      </el-table-column>
      <el-table-column label="State" align="center" prop="state" :formatter="stateFormat"/>
      <el-table-column label="Remark" align="center" prop="remark"/>
      <el-table-column label="Operation" align="center" width="140" class-name="small-padding fixed-width">
        <template slot-scope="scope">
          <el-button
            size="mini"
            type="text"
            icon="el-icon-edit"
            @click="handleUpdate(scope.row)"
            v-hasPermi="['bizsys:customer_info:edit']"
          >修改
          </el-button>
          <el-button
            size="mini"
            type="text"
            icon="el-icon-delete"
            @click="handleDelete(scope.row)"
            v-hasPermi="['bizsys:customer_info:remove']"
          >删除
          </el-button>
        </template>
      </el-table-column>
    </el-table>

    <pagination
      v-show="total>0"
      :total="total"
      :page.sync="queryParams.pageNum"
      :limit.sync="queryParams.pageSize"
      @pagination="getList"
    />

    <!-- 添加或修改客户信息对话框 -->
    <el-dialog :title="title" :visible.sync="open" width="500px" append-to-body>
      <el-form ref="form" :model="form" :rules="rules" label-width="80px">
        <el-form-item label="用户ID" prop="userId">
          <el-input v-model="form.userId" placeholder="请输入用户ID"/>
        </el-form-item>
        <el-form-item label="客户号" prop="custNo">
          <el-input v-model="form.custNo" placeholder="请输入客户号"/>
        </el-form-item>
        <el-form-item label="月收入" prop="monthlyIncome">
          <el-input v-model="form.monthlyIncome" placeholder="请输入月收入"/>
        </el-form-item>
        <el-form-item label="邮箱" prop="email">
          <el-input v-model="form.email" placeholder="请输入邮箱"/>
        </el-form-item>
        <el-form-item label="工作职称" prop="jobTitle">
          <el-select v-model="form.jobTitle" placeholder="请选择工作职称">
            <el-option
              v-for="dict in jobTitleOptions"
              :key="dict.dictValue"
              :label="dict.dictLabel"
              :value="dict.dictValue"
            ></el-option>
          </el-select>
        </el-form-item>
        <el-form-item label="工作职称-其他" prop="jobTitleOther">
          <el-select v-model="form.jobTitleOther" placeholder="请选择工作职称">
            <el-option
              v-for="dict in jobTitleOptions"
              :key="dict.dictValue"
              :label="dict.dictLabel"
              :value="dict.dictValue"
            ></el-option>
          </el-select>
        </el-form-item>
        <el-form-item label="行业" prop="industry">
          <el-select v-model="form.industry" placeholder="请选择行业">
            <el-option
              v-for="dict in industryOptions"
              :key="dict.dictValue"
              :label="dict.dictLabel"
              :value="dict.dictValue"
            ></el-option>
          </el-select>
        </el-form-item>
        <el-form-item label="婚姻状态" prop="maritalStatus">
          <el-select v-model="form.maritalStatus" placeholder="请选择婚姻状态">
            <el-option
              v-for="dict in maritalStatusOptions"
              :key="dict.dictValue"
              :label="dict.dictLabel"
              :value="dict.dictValue"
            ></el-option>
          </el-select>
        </el-form-item>
        <el-form-item label="学历" prop="degree">
          <el-select v-model="form.degree" placeholder="请选择学历">
            <el-option
              v-for="dict in degreeOptions"
              :key="dict.dictValue"
              :label="dict.dictLabel"
              :value="dict.dictValue"
            ></el-option>
          </el-select>
        </el-form-item>
        <el-form-item label="职业" prop="occupation">
          <el-select v-model="form.occupation" placeholder="请选择职业">
            <el-option
              v-for="dict in occupationOptions"
              :key="dict.dictValue"
              :label="dict.dictLabel"
              :value="dict.dictValue"
            ></el-option>
          </el-select>
        </el-form-item>
        <el-form-item label="职业-其他" prop="occupationOther">
          <el-select v-model="form.occupationOther" placeholder="请选择职业">
            <el-option
              v-for="dict in occupationOptions"
              :key="dict.dictValue"
              :label="dict.dictLabel"
              :value="dict.dictValue"
            ></el-option>
          </el-select>
        </el-form-item>
        <el-form-item label="联系人姓名" prop="relateName">
          <el-input v-model="form.relateName" placeholder="请输入联系人姓名"/>
        </el-form-item>
        <el-form-item label="联系人手机号码" prop="relatePhone">
          <el-input v-model="form.relatePhone" placeholder="请输入联系人手机号码"/>
        </el-form-item>
        <el-form-item label="关系" prop="relation">
          <el-select v-model="form.relation" placeholder="请选择关系">
            <el-option
              v-for="dict in relationOptions"
              :key="dict.dictValue"
              :label="dict.dictLabel"
              :value="dict.dictValue"
            ></el-option>
          </el-select>
        </el-form-item>

        <el-form-item label="联系人姓名2" prop="relateName">
          <el-input v-model="form.relateName2" placeholder="请输入联系人姓名"/>
        </el-form-item>
        <el-form-item label="联系人手机号码2" prop="relatePhone">
          <el-input v-model="form.relatePhone2" placeholder="请输入联系人手机号码"/>
        </el-form-item>
        <el-form-item label="关系2" prop="relation">
          <el-select v-model="form.relation2" placeholder="请选择关系">
            <el-option
              v-for="dict in relationOptions"
              :key="dict.dictValue"
              :label="dict.dictLabel"
              :value="dict.dictValue"
            ></el-option>
          </el-select>
        </el-form-item>
        <el-form-item label="复工时间" prop="resumptionDate">
          <el-date-picker clearable size="small"
                          v-model="form.resumptionDate"
                          type="date"
                          value-format="yyyy-MM-dd"
                          placeholder="选择复工时间">
          </el-date-picker>
        </el-form-item>
        <el-form-item label="发薪时间" prop="salaryDate">
          <el-date-picker clearable size="small"
                          v-model="form.salaryDate"
                          type="date"
                          value-format="yyyy-MM-dd"
                          placeholder="选择发薪时间">
          </el-date-picker>
        </el-form-item>
        <el-form-item label="工作地" prop="workingAddress">
          <el-input v-model="form.workingAddress" placeholder="请输入工作地"/>
        </el-form-item>
        <el-form-item label="工作地街道" prop="street">
          <el-input v-model="form.street" placeholder="请输入工作地"/>
        </el-form-item>
        <el-form-item label="居住地" prop="stateOfResidence">
          <el-input v-model="form.stateOfResidence" placeholder="请输入居住地"/>
        </el-form-item>
        <el-form-item label="孩子个数" prop="childrenNumber">
          <el-input v-model="form.childrenNumber" placeholder="请输入您有几个孩子"/>
        </el-form-item>
        <el-form-item label="宗教" prop="religion">
          <el-input v-model="form.religion" placeholder="请输入宗教"/>
        </el-form-item>
        <el-form-item label="母语" prop="nativeLanguage">
          <el-input v-model="form.nativeLanguage" placeholder="请输入母语"/>
        </el-form-item>
        <el-form-item label="测算提额" prop="preLine">
          <el-input v-model="form.preLine" placeholder="请输入测算提额"/>
        </el-form-item>
        <el-form-item label="模型评级" prop="modelLevel">
          <el-input v-model="form.modelLevel" placeholder="请输入模型评级"/>
        </el-form-item>
        <el-form-item label="征信有效期" prop="expiryDate">
          <el-input v-model="form.expiryDate" placeholder="请输入征信有效期"/>
        </el-form-item>
        <el-form-item label="学历更新时间" prop="degreeUpdated">
          <el-date-picker clearable size="small"
                          v-model="form.degreeUpdated"
                          type="date"
                          value-format="yyyy-MM-dd"
                          placeholder="选择学历更新时间">
          </el-date-picker>
        </el-form-item>
        <el-form-item label="职业更新时间" prop="occupationUpdated">
          <el-date-picker clearable size="small"
                          v-model="form.occupationUpdated"
                          type="date"
                          value-format="yyyy-MM-dd"
                          placeholder="选择职业更新时间">
          </el-date-picker>
        </el-form-item>
        <el-form-item label="联系人更新时间" prop="relateUpdated">
          <el-date-picker clearable size="small"
                          v-model="form.relateUpdated"
                          type="date"
                          value-format="yyyy-MM-dd"
                          placeholder="选择联系人更新时间">
          </el-date-picker>
        </el-form-item>
        <el-form-item label="状态" prop="state">
          <el-select v-model="form.state" placeholder="请选择状态">
            <el-option
              v-for="dict in stateOptions"
              :key="dict.dictValue"
              :label="dict.dictLabel"
              :value="dict.dictValue"
            ></el-option>
          </el-select>
        </el-form-item>
        <el-form-item label="备注" prop="remark">
          <el-input v-model="form.remark" placeholder="请输入备注"/>
        </el-form-item>
      </el-form>
      <div slot="footer" class="dialog-footer">
        <el-button type="primary" @click="submitForm">确 定</el-button>
        <el-button @click="cancel">取 消</el-button>
      </div>
    </el-dialog>
  </div>
</template>

<script>
import {listCustomer_info, getCustomer_info, delCustomer_info, addCustomer_info, updateCustomer_info, exportCustomer_info} from "@/api/bizsys/customer_info";

export default {
  name: "Customer_info",
  components: {},
  data() {
    return {
      // 遮罩层
      loading: true,
      // 选中数组
      ids: [],
      // 非单个禁用
      single: true,
      // 非多个禁用
      multiple: true,
      // 显示搜索条件
      showSearch: true,
      // 总条数
      total: 0,
      // 客户信息表格数据
      customer_infoList: [],
      // 弹出层标题
      title: "",
      // 是否显示弹出层
      open: false,
      // 工作职称字典
      jobTitleOptions: [],
      // 行业字典
      industryOptions: [],
      // 婚姻状态字典
      maritalStatusOptions: [],
      // 学历字典
      degreeOptions: [],
      // 职业字典
      occupationOptions: [],
      // 关系字典
      relationOptions: [],
      // 状态字典
      stateOptions: [],
      // 查询参数
      queryParams: {
        pageNum: 1,
        pageSize: 10,
        userId: null,
        custNo: null,
        monthlyIncome: null,
        email: null,
        jobTitle: null,
        industry: null,
        maritalStatus: null,
        degree: null,
        occupation: null,
        relateName: null,
        relatePhone: null,
        relation: null,
        degreeUpdated: null,
        occupationUpdated: null,
        relateUpdated: null,
        state: null,
      },
      // 表单参数
      form: {},
      // 表单校验
      rules: {
        userId: [
          {required: true, message: "用户ID不能为空", trigger: "blur"}
        ],
        custNo: [
          {required: true, message: "客户号不能为空", trigger: "blur"}
        ],
        monthlyIncome: [
          {required: true, message: "月收入不能为空", trigger: "blur"}
        ],
        email: [
          {required: true, message: "邮箱不能为空", trigger: "blur"}
        ],
        jobTitle: [
          {required: true, message: "工作职称不能为空", trigger: "change"}
        ],
        industry: [
          {required: true, message: "行业不能为空", trigger: "change"}
        ],
        maritalStatus: [
          {required: true, message: "婚姻状态不能为空", trigger: "change"}
        ],
        degree: [
          {required: true, message: "学历不能为空", trigger: "change"}
        ],
        occupation: [
          {required: true, message: "职业不能为空", trigger: "change"}
        ],
        relateName: [
          {required: true, message: "联系人姓名不能为空", trigger: "blur"}
        ],
        relatePhone: [
          {required: true, message: "联系人手机号码不能为空", trigger: "blur"}
        ],
        relation: [
          {required: true, message: "关系不能为空", trigger: "change"}
        ],
        createTime: [
          {required: true, message: "创建时间不能为空", trigger: "blur"}
        ],
        updateTime: [
          {required: true, message: "更新时间不能为空", trigger: "blur"}
        ]
      }
    };
  },
  created() {
    this.loading = false;
    // this.getList();
    this.getDicts("job_title").then(response => {
      this.jobTitleOptions = response.data;
    });
    this.getDicts("industry").then(response => {
      this.industryOptions = response.data;
    });
    this.getDicts("marital_status").then(response => {
      this.maritalStatusOptions = response.data;
    });
    this.getDicts("education").then(response => {
      this.degreeOptions = response.data;
    });
    this.getDicts("occupation").then(response => {
      this.occupationOptions = response.data;
    });
    this.getDicts("relation").then(response => {
      this.relationOptions = response.data;
    });
    this.getDicts("state").then(response => {
      this.stateOptions = response.data;
    });
  },
  methods: {
    /** 查询客户信息列表 */
    getList() {
      this.loading = true;
      listCustomer_info(this.queryParams).then(response => {
        this.customer_infoList = response.rows;
        this.total = response.total;
        this.loading = false;
      });
    },
    // 工作职称字典翻译
    jobTitleFormat(row, column) {
      return this.selectDictLabel(this.jobTitleOptions, row.jobTitle);
    },
    // 行业字典翻译
    industryFormat(row, column) {
      return this.selectDictLabel(this.industryOptions, row.industry);
    },
    // 婚姻状态字典翻译
    maritalStatusFormat(row, column) {
      return this.selectDictLabel(this.maritalStatusOptions, row.maritalStatus);
    },
    // 学历字典翻译
    degreeFormat(row, column) {
      return this.selectDictLabel(this.degreeOptions, row.degree);
    },
    // 职业字典翻译
    occupationFormat(row, column) {
      return this.selectDictLabel(this.occupationOptions, row.occupation);
    },
    // 关系字典翻译
    relationFormat(row, column) {
      return this.selectDictLabel(this.relationOptions, row.relation);
    },
    // 状态字典翻译
    stateFormat(row, column) {
      return this.selectDictLabel(this.stateOptions, row.state);
    },
    // 取消按钮
    cancel() {
      this.open = false;
      this.reset();
    },
    // 表单重置
    reset() {
      this.form = {
        id: null,
        userId: null,
        custNo: null,
        monthlyIncome: null,
        email: null,
        jobTitle: null,
        industry: null,
        maritalStatus: null,
        jobTitleOther: null,
        degree: null,
        occupation: null,
        relateName: null,
        relatePhone: null,
        resumptionDate: null,
        relation: null,
        salaryDate: null,
        workingAddress: null,
        relateName2: null,
        street: null,
        relatePhone2: null,
        stateOfResidence: null,
        relation2: null,
        degreeUpdated: null,
        childrenNumber: null,
        occupationUpdated: null,
        religion: null,
        relateUpdated: null,
        nativeLanguage: null,
        preLine: null,
        modelLevel: null,
        occupationOther: null,
        expiryDate: null,
        state: null,
        remark: null,
        createBy: null,
        createTime: null,
        updateBy: null,
        updateTime: null,
        /*id: null,
        userId: null,
        custNo: null,
        monthlyIncome: null,
        email: null,
        jobTitle: null,
        industry: null,
        maritalStatus: null,
        degree: null,
        occupation: null,
        relateName: null,
        relatePhone: null,
        relation: null,
        degreeUpdated: null,
        occupationUpdated: null,
        relateUpdated: null,
        state: null,
        remark: null,
        createBy: null,
        createTime: null,
        updateBy: null,
        updateTime: null*/
      };
      this.resetForm("form");
    },
    /** 搜索按钮操作 */
    handleQuery() {
      this.queryParams.pageNum = 1;
      this.getList();
    },
    /** 重置按钮操作 */
    resetQuery() {
      this.resetForm("queryForm");
      this.handleQuery();
    },
    // 多选框选中数据
    handleSelectionChange(selection) {
      this.ids = selection.map(item => item.id)
      this.single = selection.length !== 1
      this.multiple = !selection.length
    },
    /** 新增按钮操作 */
    handleAdd() {
      this.reset();
      this.open = true;
      this.title = "添加客户信息";
    },
    /** 修改按钮操作 */
    handleUpdate(row) {
      this.reset();
      const id = row.id || this.ids
      getCustomer_info(id).then(response => {
        this.form = response.data;
        this.open = true;
        this.title = "修改客户信息";
      });
    },
    /** 提交按钮 */
    submitForm() {
      this.$refs["form"].validate(valid => {
        if (valid) {
          if (this.form.id != null) {
            updateCustomer_info(this.form).then(response => {
              this.msgSuccess("修改成功");
              this.open = false;
              this.getList();
            });
          } else {
            addCustomer_info(this.form).then(response => {
              this.msgSuccess("新增成功");
              this.open = false;
              this.getList();
            });
          }
        }
      });
    },
    /** 删除按钮操作 */
    handleDelete(row) {
      const ids = row.id || this.ids;
      this.$confirm('是否确认删除客户信息编号为"' + ids + '"的数据项?', "警告", {
        confirmButtonText: "确定",
        cancelButtonText: "取消",
        type: "warning"
      }).then(function () {
        return delCustomer_info(ids);
      }).then(() => {
        this.getList();
        this.msgSuccess("删除成功");
      })
    },
    /** 导出按钮操作 */
    handleExport() {
      const queryParams = this.queryParams;
      this.$confirm('是否确认导出所有客户信息数据项?', "警告", {
        confirmButtonText: "确定",
        cancelButtonText: "取消",
        type: "warning"
      }).then(function () {
        return exportCustomer_info(queryParams);
      }).then(response => {
        this.download(response.msg);
      })
    }
  }
};
</script>
